package com.ecust.Controller.User;

import com.ecust.Entity.User.User;
import com.ecust.Service.User.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Created by admin on 2017/4/29.
 * @Description 用户登录控制器
 * @author  mengweiqiang
 */
@Controller
@RequestMapping(value = "/login/**")
public class UserLoginController {
    @Autowired
    private UserService userService;
    @RequestMapping(value="UserLogin",method = RequestMethod.POST)
    public String User_Login(@RequestParam String UserID, @RequestParam String UserPwd , @RequestParam String RoleID, Model model)
    {
        boolean LoginFlag = userService.getFindUser(UserID,UserPwd,RoleID);
        if (LoginFlag)
        {
            User user = userService.getFindUserInfo(UserID).get(0);
            model.addAttribute("user",user);
            return "/EvaluationHome";
        }
        else
        {
            return "/LoginFailure";
        }
    }
}
